/*
 * Copyright (c) 2019. seven studio. @chengdu
 * seven studio in chengdu by lb
 * this project for snmp tool
 */

package com.xlx.openLink.enums;

import org.apache.commons.lang3.StringUtils;

public enum AlLevel {

    AL_COMMON("AL_COMMON","一般告警"),
    AL_SEVERITY("AL_SEVERITY","严重告警"),
    AL_DEADLY("AL_DEADLY","毁灭告警");

    private String code;
    private String desc;

    AlLevel(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     *
     * @param code
     * @return
     */
    public static AlLevel getByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }

        for (AlLevel result : values()) {
            if (code.equalsIgnoreCase(result.getCode())) {
                return result;
            }
        }
        return null;
    }

    /**
     *
     * @param desc
     * @return
     */
    public static AlLevel getByDesc(String desc) {
        if (StringUtils.isBlank(desc)) {
            return null;
        }

        for (AlLevel result : values()) {
            if (desc.equalsIgnoreCase(result.getDesc())) {
                return result;
            }
        }
        return null;
    }


}
